import util from "@/libs/util";

export default ({ request }) => ({
  /**
   * @description 创建订单
   * @param {Object} data
   */
  PLACE_ORDER(data = {}) {
    let userinfo = util.store.getItem("userinfo");
    data.id = userinfo.user_id;
    data.manual = 3;

    return request({
      url: "/data/v1/placeOrder",
      method: "post",
      data: data,
    });
  },
  /**
   * 确认下单
   * @param {*} order_number
   * @returns
   */
  ORDER_DETERMINE(order_number) {
    let userinfo = util.store.getItem("userinfo");

    return request({
      url: "/data/v1/orderDetermine",
      method: "post",
      data: {
        order_number,
        id: userinfo.user_id,
      },
    });
  },
  ORDER_DATAILS(order_number) {
    let userinfo = util.store.getItem("userinfo");
    return request({
      url: "/data/v1/orderDetails",
      method: "post",
      data: {
        order_number,
        id: userinfo.user_id,
      },
    });
  },
  ORDER_TKYY() {
    return request({
      url: "/data/v1/returnReasonList",
      method: "post",
    });
  },
  /**
   * 订单列表
   * @param {*} data
   * @returns
   */
  ORDER_LIST(data = {}) {
    let userinfo = util.store.getItem("userinfo");
    data.id = userinfo.user_id;
    return request({
      url: "/data/v1/orderList",
      method: "post",
      data: data,
    });
  },
  /**
   * 退款售后订单
   * @param {*} data
   * @returns
   */
  ORDER_RETURN_LIST(data = {}) {
    let userinfo = util.store.getItem("userinfo");
    data.id = userinfo.user_id;
    return request({
      url: "/data/v1/orderApplication",
      method: "post",
      data: data,
    });
  },

  ORDER_GOODS(data = {}) {
    let userinfo = util.store.getItem("userinfo");
    data.id = userinfo.user_id;
    return request({
      url: "/data/v1/myCartGood",
      method: "post",
      data: data,
    });
  },
  ORDER_ADD_RETURN(data = {}) {
    let userinfo = util.store.getItem("userinfo");
    data.id = userinfo.user_id;
    return request({
      url: "/data/v1/orderApplicationAdd",
      method: "post",
      data: data,
    });
  },
  /**
   * 取消订单
   * @param {*} order_number
   * @returns
   */
  ORDER_CLEAR(order_number) {
    let userinfo = util.store.getItem("userinfo");

    return request({
      url: "/data/v1/orderCancel",
      method: "post",
      data: {
        order_number,
        id: userinfo.user_id,
      },
    });
  },
});
